(load-plugin "markdown-mode")

(autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t)
(setq auto-mode-alist (cons '("\\.text" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.md" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.MD" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.markdown" . markdown-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.mdown" . markdown-mode) auto-mode-alist))
;;(setq auto-mode-alist (cons '("^*markdown-output*$" . html-mode) auto-mode-alist))

(defun show-markdown-output()
  (interactive)
  (setq temp-buffer-name (buffer-name (current-buffer)))
  (show-output-window "*markdown-output*")
  (markdown)
  (switch-to-buffer-other-window temp-buffer-name)
  (show-output-window "*markdown-output*"))

(defun markdown-custom-settings ()
  "markdown-mode-hook"
  (setq markdown-command "markdown | smartypants")
  (define-key markdown-mode-map [f1] 'show-markdown-output)
  (define-key markdown-mode-map (kbd "C-c z") 'show-markdown-output))

(add-hook 'markdown-mode-hook '(lambda() (markdown-custom-settings)))

(provide 'mod-markdown)
